package nl.saxion.saktiehuis.dao;

import java.util.List;

import nl.saxion.saktiehuis.model.Product;
import nl.saxion.saktiehuis.util.AbstractDaoImpl;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

@Repository
public class ProductDaoImpl extends AbstractDaoImpl<Product> implements
		ProductDao {

	@Override
	public Product getProductById(int id) {
		Criteria criteria = getSession().createCriteria(Product.class);
		criteria.add(Restrictions.eq("id", id));
		return (Product) criteria.uniqueResult();
	}

	@Override
	public List<Product> getSelectie(String type) {
		Criteria criteria = getSession().createCriteria(Product.class);
		criteria.add(Restrictions.eq("type", type));
		return criteria.list();
	}

	@Override
	public List<Product> getAlleProducten() {
		Criteria criteria = getSession().createCriteria(Product.class);
		return criteria.list();
	}

}
